|
|
|
|
|
|
|
(table continued from previous page) |
|
|
|
|
| [As Type] | Functions should always specify a return type, typically As Long. One of the most common mistakes made with the Declare statement is to forget to specify a return type. You can also specify the function type by adding a type character to the name of the function (such as % for integer and & for long). | | Table T1-1: Elements in the Declare Statement |
|
|
|
|
|
|
Finding Exported Functions |
|
|
|
|
|
|
|
|
The Windows operating system is made up of a great many DLLs, and figuring out which DLL contains a particular API function can be quite a challenge. Fortunately, there are a number of tools and techniques that can help. |
|
|
|
|
|
|
|
|
By far the easiest way to find a DLL for a function is to look at an existing correct declaration. There are two primary sources of declarations available to you: the win32api.txt file provided with Visual Basic, and the api32.txt file included on the CD with this book. Now, I must stress the importance of finding a correct declaration, because both of these files may contain errors. The api32.txt file fixes many errors in the win32api.txt file (on which it is based) and did not contain any known errors at the time this book went to press, but I won't claim that it is perfect. |
|
|
|
|
|
|
|
|
The major limitation with these two files is that they do not contain declarations for every API function. They can'tMicrosoft adds new functions and DLLs almost daily. |
|
|
|
|
|
|
|
|
You see, that's how Windows grows. Microsoft rarely adds new functions to existing DLLs. Instead, they create new DLLs that implement the new functionality. This suggests the next-best approach to determine the DLL that contains a functioncommon sense. |
|
|
|
|
|
|
|
|
Table T1-2 below lists some of the most frequently used DLLs and the functionality they implement. If you know what a function does, you can often guess the DLL based on that information. For example, if you have a function that performs a graphic operation on a window, there is an excellent chance that it is in gdi32.dll, the graphic device interface library. |
|
|
|
|
| kernel32.dll | This DLL contains functions that implement the operating system kernel. Process management, system functionality, memory management, and most device I/O functions are found in this DLL. You need not include the .dll extension when referring to this DLL in your Visual Basic declaration. | user32.dll | This DLL contains functions that implement the windows-based user interface. Functions that create and manage |
|
|
|
|
|
|
(table continued on next page) |
|
|
|
|
|